package com.joesem.sale.client.getui

import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.util.Log
import com.joesem.sale.client.db.LoginTable
import com.joesem.sale.client.logic.home.MainActivity
import com.joesem.sale.client.logic.login.LoginActivity


class NoticeReceiver : BroadcastReceiver() {
    override fun onReceive(context: Context?, intent: Intent?) {
        if (LoginTable.table.isLogin())
            Intent(context, MainActivity::class.java).apply {
                flags = Intent.FLAG_ACTIVITY_NEW_TASK
                intent?.getParcelableExtra<NoticeDataMode>("noticeData")?.let {
                    putExtra("business_id", it.business_id)
                    putExtra("notify_type", it.notify_type)
                }
                context?.startActivity(this)
            }
        else {
            context?.startActivity(Intent(context, LoginActivity::class.java))
        }
    }
}